using System;
using System.Collections.Generic;
using System.Text;
using System.Data;

namespace DTO
{
	/// <summary> 
	///Author: nnamthach@gmail.com 
	/// <summary>
	
    public class LIST_CHARTInfo
    {
		#region Local Variable
		public enum Field
		{
			DTB,
			ID,
			IDGadget,
			SheetChart,
			NameRange,
			CaptionRange,
			SubCaptionRange,
			ChartType,
			PositionReplace,
			width,
			height
		}
		private String _DTB;
		private Int32 _ID;
		private Int32 _IDGadget;
		private String _SheetChart;
		private String _NameRange;
		private String _CaptionRange;
		private String _SubCaptionRange;
		private String _ChartType;
		private String _PositionReplace;
		private Int32 _width;
		private Int32 _height;
		
		public String DTB{	get{ return _DTB;} set{_DTB = value;} }
		public Int32 ID{	get{ return _ID;} set{_ID = value;} }
		public Int32 IDGadget{	get{ return _IDGadget;} set{_IDGadget = value;} }
		public String SheetChart{	get{ return _SheetChart;} set{_SheetChart = value;} }
		public String NameRange{	get{ return _NameRange;} set{_NameRange = value;} }
		public String CaptionRange{	get{ return _CaptionRange;} set{_CaptionRange = value;} }
		public String SubCaptionRange{	get{ return _SubCaptionRange;} set{_SubCaptionRange = value;} }
		public String ChartType{	get{ return _ChartType;} set{_ChartType = value;} }
		public String PositionReplace{	get{ return _PositionReplace;} set{_PositionReplace = value;} }
		public Int32 width{	get{ return _width;} set{_width = value;} }
		public Int32 height{	get{ return _height;} set{_height = value;} }
		
        #endregion LocalVariable
        
        #region Constructor
		public LIST_CHARTInfo()
		{
			_DTB = "";
			_ID = 0;
			_IDGadget = 0;
            _SheetChart = "data";
			_NameRange = "chart";
			_CaptionRange = "caption";
			_SubCaptionRange = "subcaption";
            _ChartType = "Column3D";
            _PositionReplace = "*CHART*";
			_width = 200;
			_height = 200;
		}
		public LIST_CHARTInfo(
		String DTB,
		Int32 ID,
		Int32 IDGadget,
		String SheetChart,
		String NameRange,
		String CaptionRange,
		String SubCaptionRange,
		String ChartType,
		String PositionReplace,
		Int32 width,
		Int32 height
		)
		{
			_DTB = DTB;
			_ID = ID;
			_IDGadget = IDGadget;
			_SheetChart = SheetChart;
			_NameRange = NameRange;
			_CaptionRange = CaptionRange;
			_SubCaptionRange = SubCaptionRange;
			_ChartType = ChartType;
			_PositionReplace = PositionReplace;
			_width = width;
			_height = height;
		}
		public LIST_CHARTInfo(DataRow dr)
		{
			if (dr != null)
			{
				_DTB = dr[Field.DTB.ToString()] == DBNull.Value?"":Convert.ToString(dr[Field.DTB.ToString()]);
				_ID = dr[Field.ID.ToString()] == DBNull.Value?0:Convert.ToInt32(dr[Field.ID.ToString()]);
				_IDGadget = dr[Field.IDGadget.ToString()] == DBNull.Value?0:Convert.ToInt32(dr[Field.IDGadget.ToString()]);
				_SheetChart = dr[Field.SheetChart.ToString()] == DBNull.Value?"":Convert.ToString(dr[Field.SheetChart.ToString()]);
				_NameRange = dr[Field.NameRange.ToString()] == DBNull.Value?"":Convert.ToString(dr[Field.NameRange.ToString()]);
				_CaptionRange = dr[Field.CaptionRange.ToString()] == DBNull.Value?"":Convert.ToString(dr[Field.CaptionRange.ToString()]);
				_SubCaptionRange = dr[Field.SubCaptionRange.ToString()] == DBNull.Value?"":Convert.ToString(dr[Field.SubCaptionRange.ToString()]);
				_ChartType = dr[Field.ChartType.ToString()] == DBNull.Value?"":Convert.ToString(dr[Field.ChartType.ToString()]);
				_PositionReplace = dr[Field.PositionReplace.ToString()] == DBNull.Value?"":Convert.ToString(dr[Field.PositionReplace.ToString()]);
				_width = dr[Field.width.ToString()] == DBNull.Value?0:Convert.ToInt32(dr[Field.width.ToString()]);
				_height = dr[Field.height.ToString()] == DBNull.Value?0:Convert.ToInt32(dr[Field.height.ToString()]);
			}
		}
		public LIST_CHARTInfo(LIST_CHARTInfo objEntr)
		{			
			_DTB = objEntr.DTB;			
			_ID = objEntr.ID;			
			_IDGadget = objEntr.IDGadget;			
			_SheetChart = objEntr.SheetChart;			
			_NameRange = objEntr.NameRange;			
			_CaptionRange = objEntr.CaptionRange;			
			_SubCaptionRange = objEntr.SubCaptionRange;			
			_ChartType = objEntr.ChartType;			
			_PositionReplace = objEntr.PositionReplace;			
			_width = objEntr.width;			
			_height = objEntr.height;			
		}
        #endregion Constructor
        
        #region InitTable
		public static DataTable ToDataTable()
		{
			DataTable dt = new DataTable("LIST_CHART");
			dt.Columns.AddRange(new DataColumn[] { 
				new DataColumn(Field.DTB.ToString(), typeof(String)),
				new DataColumn(Field.ID.ToString(), typeof(Int32)),
				new DataColumn(Field.IDGadget.ToString(), typeof(Int32)),
				new DataColumn(Field.SheetChart.ToString(), typeof(String)),
				new DataColumn(Field.NameRange.ToString(), typeof(String)),
				new DataColumn(Field.CaptionRange.ToString(), typeof(String)),
				new DataColumn(Field.SubCaptionRange.ToString(), typeof(String)),
				new DataColumn(Field.ChartType.ToString(), typeof(String)),
				new DataColumn(Field.PositionReplace.ToString(), typeof(String)),
				new DataColumn(Field.width.ToString(), typeof(Int32)),
				new DataColumn(Field.height.ToString(), typeof(Int32))
			});
			return dt;
		}
		public DataRow ToDataRow(DataTable dt)
		{
			DataRow row = dt.NewRow();
			row[Field.DTB.ToString()] = _DTB;
			row[Field.ID.ToString()] = _ID;
			row[Field.IDGadget.ToString()] = _IDGadget;
			row[Field.SheetChart.ToString()] = _SheetChart;
			row[Field.NameRange.ToString()] = _NameRange;
			row[Field.CaptionRange.ToString()] = _CaptionRange;
			row[Field.SubCaptionRange.ToString()] = _SubCaptionRange;
			row[Field.ChartType.ToString()] = _ChartType;
			row[Field.PositionReplace.ToString()] = _PositionReplace;
			row[Field.width.ToString()] = _width;
			row[Field.height.ToString()] = _height;
			return row;
		}
        #endregion InitTable
    }
}
